
package net.sf.odinms.server.maps;

import java.awt.Point;

import net.sf.odinms.client.MapleCharacter;
import net.sf.odinms.client.MapleClient;
import net.sf.odinms.client.SkillFactory;
import net.sf.odinms.client.skills.*;
import net.sf.odinms.tools.MaplePacketCreator;

/**
 *
 * @author Jan
 */
public class MapleSummon extends AbstractAnimatedMapleMapObject {

    private MapleCharacter owner;
    private int skillLevel = 1;
    private int skill;
    private int hp;
    private int status;
    private int removeStatus;
    private SummonMovementType movementType;

    public MapleSummon(MapleCharacter owner, int skill, Point pos, SummonMovementType movementType) {
        this.owner = owner;
        this.skill = skill;
        if (skill == 35121011) {
            this.skillLevel = 1;
        } else {
            this.skillLevel = owner.getSkillLevel(SkillFactory.getSkill(skill));
        }
        this.movementType = movementType;
        if (isPuppet() || isStationary() || isRobot() || skill == 3310100) { //3310100 地雷
            this.status = 0;
        } else if (isRobot2()){
            this.status = 0;
            this.removeStatus = 5;
        } else if (skill == 35121003) {
            this.status = 5;
        } else if (isBeholder()) {
            this.status = 2;
            this.removeStatus = 12;
        } else if (is人造卫星()) {
            this.status = 3;
            this.removeStatus = 10;
        } else if (skill == 35121009) {
            this.status = 4;
        } else if (skill == 35121011) { //机器人工厂召唤出来的小机器人
            this.removeStatus = 5;
        } else if (isDarkJuggling()) { //黑暗杂耍
            this.status = 6;
            this.removeStatus = 0;
        } else {
            this.status = 1;
            this.removeStatus = 4;
        }
        setPosition(pos);
    }

    public void sendSpawnData(MapleClient client) {
        client.getSession().write(MaplePacketCreator.spawnSpecialMapObject(this, skillLevel, true));
    }

    public void sendDestroyData(MapleClient client) {
        client.getSession().write(MaplePacketCreator.removeSpecialMapObject(this, true));
    }

    public MapleCharacter getOwner() {
        return this.owner;
    }

    public int getSkill() {
        return this.skill;
    }

    public int getStatus() {
        return status;
    }

    public int getHP() {
        return this.hp;
    }

    public int getRemoveStatus(){
        return removeStatus;
    }
    public void addHP(int delta) {
        this.hp += delta;
    }

    public SummonMovementType getMovementType() {
        return movementType;
    }

    public boolean isPuppet() {
        return (skill == 4341006);
    }

    public boolean isDarkJuggling() {
        return (skill == 4111007 || skill == 4211007);
    }

    public boolean isStationary() {
        return (skill == 弓手.替身术 || skill == 弩手.替身术 || skill == 5211001 || skill == 13111004);
    }

    public boolean isRobot() {
        return skill == 机械师.磁场;
    }

    public boolean isRobot2() { //加速器 放大器
        return skill == 35111005 || skill == 35121010;
    }

    public boolean is人造卫星() {
        return (skill == 机械师.人造卫星 || skill == 机械师.人造卫星2 || skill == 机械师.人造卫星3);
    }

    public boolean isBeholder() {
        return skill == 1321007;
    }

    public int getSkillLevel() {
        return skillLevel;
    }

    public boolean isBuffSummon() {
        switch(skill){
            case 弓手.银鹰召唤: // 银鹰召唤
            case 弩手.金鹰召唤: // 金鹰召唤
            case 弩骑.银鹰: // 银鹰召唤
            case 火毒.火魔兽: // 火魔兽
            case 冰雷.冰破魔兽 ://冰魔兽 ++
            case 弓手.火凤凰:// 火凤凰 ++
            case 弩手.冰凤凰: //冰凤凰
            case 弓手.替身术: // 射手 - 替身术
            case 弩手.替身术: // 游侠 - 替身术
            case 双刀.傀儡召唤: // 暗影双刀 - 傀儡召唤
            case 风灵使者.替身术: //风灵使者 - 替身术
            case 弩骑.野性陷阱: //野性陷阱
                return true;
        }
        return false;
    }
    @Override
    public MapleMapObjectType getType() {
        return MapleMapObjectType.SUMMON;
    }
}
